package com.lovo.Util;

import java.util.Locale;
import java.util.Scanner;

public class Camel {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入一个大写英文单词");
        String num=scan.next();
        System.out.println("蛇形："+camelToSnake(num));
    }

    public static String camelToSnake(String num){
        String str="";
        String[] str1=num.split("");
        for (int i=0;i<str1.length;i++){
            if (i==0) {
                continue;
            }
            char[]b=str1[i].toCharArray();
            if (Character.isUpperCase(b[0])){
                str1[i]="_"+str1[i];
            }
        }
        for (String items:str1){
            str+=items;
        }
        return str.toLowerCase();
    }
}
